home *** CD-ROM | disk | FTP | other *** search
/ World of Education / World of Education.iso / world_p / pcshx10b.zip / PCSHX10B.EXE / GNUFGREP.EXE / GREPDOCS.EXE / GREP.LPR < prev    next >
Text File  |  1991-08-24  |  8KB  |  241 lines

  1.  
  2.  
  3. GREP(1)         USER COMMANDS              GREP(1)
  4.  
  5.  
  6. NAME
  7.      grep, egrep - print lines matching a regular expression
  8.  
  9. SYNOPSIS
  10.      grep [ -CVbchilnsvwx ] [ -num ] [ -AB num ] [ [ -e ] expr    |
  11.      -f file ] [ files ... ]
  12.  
  13. DESCRIPTION
  14.      Grep searches the files listed in the arguments (or standard
  15.      input  if    no  files are given) for all lines that contain a
  16.      match for the given expr.    If  any  lines    match,    they  are
  17.      printed.
  18.  
  19.      Also, if any matches were    found,    grep  will  exit  with    a
  20.      status  of 0, but if no matches were found it will exit with
  21.      a status of 1.  This is useful for  building  shell  scripts
  22.      that use grep as a condition for, for example, the if state-
  23.      ment.
  24.  
  25.      When invoked as egrep the syntax of  the  expr  is  slightly
  26.      different; See below.
  27.  
  28. REGULAR EXPRESSIONS
  29.       (grep)    (egrep)   (explanation)
  30.  
  31.       c        c          a   single   (non-meta)    character
  32.                   matches itself.
  33.  
  34.       .        .          matches any single character except
  35.                   newline.
  36.  
  37.       \?        ?          postfix operator;  preceeding  item
  38.                   is optional.
  39.  
  40.       *        *          postfix operator; preceeding item 0
  41.                   or more times.
  42.  
  43.       \+        +          postfix operator; preceeding item 1
  44.                   or more times.
  45.  
  46.       \|        |          infix  operator;     matches   either
  47.                   argument.
  48.  
  49.       ^        ^          matches the  empty  string  at  the
  50.                   beginning of a line.
  51.  
  52.       $        $          matches the empty string at the end
  53.                   of a line.
  54.  
  55.       \<        \<          matches the  empty  string  at  the
  56.                   beginning of a word.
  57.  
  58.  
  59.  
  60. GNU Project      Last change: 1988 December 13        1
  61.  
  62.  
  63. GREP(1)         USER COMMANDS              GREP(1)
  64.  
  65.  
  66.       \>        \>          matches the empty string at the end
  67.                   of a word.
  68.  
  69.       [chars]   [chars]   match any character  in  the  given
  70.                   class; if the first character after
  71.                   [ is ^, match any character not  in
  72.                   the given class; a range of charac-
  73.                   ters   may    be      specified    by
  74.                   first-last; for example, \W (below)
  75.                   is   equivalent    to   the    class
  76.                   [^A-Za-z0-9]
  77.  
  78.       \( \)     ( )       parentheses are  used  to  override
  79.                   operator precedence.
  80.  
  81.       \digit    \digit    \n matches a  repeat  of    the  text
  82.                   matched  earlier    in  the regexp by
  83.                   the subexpression  inside  the  nth
  84.                   opening parenthesis.
  85.  
  86.       \        \          any special character may  be  pre-
  87.                   ceded  by  a  backslash to match it
  88.                   literally.
  89.  
  90.       (the following are for compatibility with GNU Emacs)
  91.  
  92.       \b        \b          matches the  empty  string  at  the
  93.                   edge of a word.
  94.  
  95.       \B        \B          matches the empty string if not  at
  96.                   the edge of a word.
  97.  
  98.       \w        \w          matches word-constituent characters
  99.                   (letters & digits).
  100.  
  101.       \W        \W          matches  characters  that  are  not
  102.                   word-constituent.
  103.  
  104.      Operator precedence is (highest to lowest) ?, *, and +, con-
  105.      catenation, and finally |.  All other constructs are syntac-
  106.      tically identical    to  normal  characters.   For  the  truly
  107.      interested,  the  file  dfa.c describes (and implements) the
  108.      exact grammar understood by the parser.
  109.  
  110. OPTIONS
  111.      -A num
  112.       print <num> lines of context after every matching line
  113.  
  114.      -B num
  115.       print num lines of context before every matching line
  116.  
  117.      -C   print 2 lines of context on each side of every match
  118.  
  119.  
  120.  
  121. GNU Project      Last change: 1988 December 13        2
  122.  
  123.  
  124.  
  125. GREP(1)         USER COMMANDS              GREP(1)
  126.  
  127.  
  128.      -num print num lines of context on each side of every match
  129.  
  130.      -V   print the version number on the diagnostic output
  131.  
  132.      -b   print every match preceded by its byte offset
  133.  
  134.      -c   print a total count of matching lines only
  135.  
  136.      -e expr
  137.       search for expr; useful if expr begins with -
  138.  
  139.      -f file
  140.       search for the expression contained in file
  141.  
  142.      -h   don't display filenames on matches
  143.  
  144.      -i   ignore case difference when comparing strings
  145.  
  146.      -l   list files containing matches only
  147.  
  148.      -n   print each match preceded by its line number
  149.  
  150.      -s   run silently producing no output except error messages
  151.  
  152.      -v   print only lines that contain no matches for the <expr>
  153.  
  154.      -w   print only lines where the match is a complete word
  155.  
  156.      -x   print only lines where the match is a whole line
  157.  
  158. SEE ALSO
  159.      emacs(1), ed(1), sh(1), GNU Emacs Manual
  160.  
  161. INCOMPATIBILITIES
  162.      The following incompatibilities with UNIX grep exist:
  163.  
  164.       The context-dependent meaning of *  is  not  quite  the
  165.       same (grep only).
  166.  
  167.       -b prints a byte offset instead of a block offset.
  168.  
  169.       The {m,n} construct of System  V  grep  is  not  imple-
  170.       mented.
  171.  
  172. BUGS
  173.      GNU e?grep  has  been  thoroughly    debugged  and  tested  by
  174.      several  people  over  a  period of several months; we think
  175.      it's a reliable beast or we wouldn't distribute it.   If  by
  176.      some  fluke  of  the  universe  you  discover  a bug, send a
  177.      detailed description  (including  options,  regular  expres-
  178.      sions, and a copy of an input file that can reproduce it) to
  179.      me, mike@wheaties.ai.mit.edu.
  180.  
  181.  
  182.  
  183. GNU Project      Last change: 1988 December 13        3
  184.  
  185.  
  186. GREP(1)         USER COMMANDS              GREP(1)
  187.  
  188.  
  189.      There is also a newsgroup, gnu.utils.bug, for reporting  FSF
  190.      utility programs' bugs and fixes; but before reporting some-
  191.      thing as a bug, please try to be sure that it  really  is    a
  192.      bug,  not a misunderstanding or a deliberate feature.  Also,
  193.      include the version number of the utility    program  you  are
  194.      running in every bug report that you send in.  Please do not
  195.      send anything but bug reports to this newsgroup.
  196.  
  197. AVAILABILITY
  198.      GNU grep is free; anyone may redistribute copies of grep  to
  199.      anyone  under  the  terms    stated    in the GNU General Public
  200.      License, a copy of which may be found in each  copy  of  GNU
  201.      Emacs.   See also the comment at the beginning of the source
  202.      code file grep.c.
  203.  
  204.      Copies of GNU grep may sometimes be received  packaged  with
  205.      distributions  of    Unix systems, but it is never included in
  206.      the scope of  any    license  covering  those  systems.   Such
  207.      inclusion    violates  the terms on which distribution is per-
  208.      mitted.  In fact, the primary purpose of the General  Public
  209.      License  is to prohibit anyone from attaching any other res-
  210.      trictions to redistribution of  any  of  the  Free  Software
  211.      Foundation programs.
  212.  
  213. AUTHORS
  214.      Mike Haertel wrote the deterministic  regexp  code  and  the
  215.      bulk of the program.
  216.  
  217.      James A. Woods is    responsible  for  the  hybridized  search
  218.      strategy  of using Boyer-Moore-Gosper fixed-string search as
  219.      a filter before calling the general regexp matcher.
  220.  
  221.      Arthur David Olson contributed code that finds fixed strings
  222.      for  the  aforementioned  BMG  search  for  a large class of
  223.      regexps.
  224.  
  225.      Richard Stallman wrote the backtracking regexp matcher  that
  226.      is  used  for  \digit  backreferences, as well as the getopt
  227.      that is provided for 4.2BSD sites.  The backtracking matcher
  228.      was originally written for GNU Emacs.
  229.  
  230.      D. A. Gwyn wrote the C alloca emulation that is provided  so
  231.      System  V    machines  can  run this program.  (Alloca is used
  232.      only by RMS' backtracking matcher, and then only rarely,  so
  233.      there  is    no  loss  if  your  machine doesn't have a "real"
  234.      alloca.)
  235.  
  236.      Scott Anderson and Henry  Spencer    designed  the  regression
  237.      tests used in the "regress" script.
  238.  
  239.      Paul Placeway wrote the  original    version  of  this  manual
  240.      page.
  241.